import time
from libs.ocr import findString
from libs.utils import text_to_speech
from libs.appium_driver import driver
import pytz
from datetime import datetime   
china_tz = pytz.timezone('Asia/Shanghai')
success = 0
fail = 0
start_time = time.time()
while True:
    # current_time = time.time()
    # # 计算与第一次记时的时间差
    # elapsed_time = current_time - start_time
    # if(elapsed_time>30*60):
    #     text_to_speech('到30分钟')
    #     exit(0)
    strList = ['重赛','重试','好的','跳过','继续','开始对决！','枫叶丘','枫叶丘','新秩序竞技场','噩梦丘','15号摄影棚','房顶','木板路','兔子洞']
    _,_,_,res = findString(strList,tap=True,loop=True)
    if res == '继续':
        success += 1
    if res == '重赛':
        fail += 1
        print('success',success,'fail',fail-success,"北京时间:", datetime.now(china_tz).strftime('%Y-%m-%d %H:%M:%S'))
    if res == '枫叶丘':
        driver.tap(957,530)
    if res == '新秩序竞技场':
        driver.tap(961,542)
    if res == '噩梦丘':
        driver.tap(981,546)
    if res == '15号摄影棚':
        driver.tap(720,536)
    if res == '房顶':
        driver.tap(1278,553)
    if res == '木板路':
        driver.tap(789,541)
    if res == '兔子洞':
        driver.tap(938,550)
            
            
